class Serializable(object):
    def serialize(self):
        data = {}
        field_list = self.__slots__ if hasattr(self, '__slots__') else self.__dict__
        for field_name in field_list:
            format_method = getattr(self, 'get_{}'.format(
                field_name
            ), None)

            if format_method:
                data[field_name] = format_method()
            else:
                field: Serializable = getattr(self, field_name, None)
                if hasattr(field, 'serialize'):
                    data[field_name] = field.serialize()
                else:
                    data[field_name] = field
        return data
